﻿
function init() {
    comForm.bind(null, 'MATCH', { data: DataDict['data_match'], textField: 'text', valueField: 'value' }, 3);
    comForm.bind(null, 'PRORITY', { data: DataDict['data_prority'], textField: 'text', valueField: 'value' }, 3);
    if ($.getPara('dicttypeid') != '') {
        initexttype();
    }
    $('#save').bind('click', function () { save(); });


}





function deleteattach() {
    $('#attachinfo').html('');
}


//保存
function save() {
    if ($('#SUBJ_NAME').val() == '') {
        alert(lang.theme_can_not_be_empty);
        return;
    }

    $.ajaxHandler({
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "themeAdd",
        model: function () {
            var obj = {};
            if ($.getPara('dicttypeid') != '') {
                obj.SUBJ_ID = $.getPara('dicttypeid');
            }
            obj.SUBJ_NAME = $('#SUBJ_NAME').val();
            obj.PRORITY = $('#PRORITY').val();
            obj.MATCH = $('#MATCH').val();
            obj.KEYW = $('#KEYW').val();
            obj.EXT_CONT = $('#EXT_CONT').val();
            obj.WHERE_FMT = $('#WHERE_FMT').val();

            return $.toJSON(obj);
        },
        success: function (data) {
            if (data) {
                alert(lang.add_new_theme_success);
                parent.subjectList.search();
                parent.$.closePage();

            }
        }
    });
}
//编辑初始化
function initexttype() {
    $.ajaxHandler({
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "InnitSubject",
        model: function () { return $.getPara('dicttypeid'); },
        success: function (data) {
            if (data) {
                for (var key in data) {
                    if ($('#' + key).length > 0) {
                        if (key == "SUBJ_NAME")
                            $('#' + key).val(data[key]);
                        if (key == "PRORITY")
                            $('#' + key).val(data[key]);
                       
                        if (key == "MATCH") {
                            $('#' + key).val(Number(data[key]));
                        }
                        if (key == "KEYW")
                            $('#' + key).val(data[key]);
                        if (key == "EXT_CONT")
                            $('#' + key).val(data[key]);
                        if (key == "WHERE_FMT")
                            $('#' + key).val(data[key]);
                        
                    }
                }
            }
        }
    });

   
}
function exit() {
    parent.$.closePage();
}